package com.example.anew.journey.mynewjourney.firstchangelogic.FirstChangeMain.model;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.anew.journey.mynewjourney.bean.ISFirstBean;
import com.example.anew.journey.mynewjourney.firstchangelogic.FirstChangeMain.bean.MainDateBean;

import static android.content.Context.MODE_PRIVATE;


/**
 * 杭州惟君医疗科技有限公司15
 * Created by 20433 on 2018/3/24
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class FirstChangeMainModel implements ISFirstChangeMainModel {

    @Override
    public MainDateBean TakeData(Context mContext) {
        MainDateBean mainDateBean =  new MainDateBean();
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        String my_use_id = sharedPreferences.getString("my_use_id", "");
        String my_use_name = sharedPreferences.getString("my_use_name", "");
        String my_use_logo = sharedPreferences.getString("my_use_logo", "");
        String my_use_token = sharedPreferences.getString("my_use_token", "");
        mainDateBean.setId(my_use_id);
        mainDateBean.setToken(my_use_token);
        mainDateBean.setCus_logo(my_use_logo);
        mainDateBean.setCus_name(my_use_name);
        return mainDateBean;
    }

    @Override
    public String TakeNiName(Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
       String  my_use_logo =  sharedPreferences.getString("my_use_name","");

        return my_use_logo;
    }

    @Override
    public String TakeHeadPortrait(Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        String my_use_name = sharedPreferences.getString("my_use_logo", "");
        return my_use_name;
    }

    @Override
    public int getVersionCode(Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        int versioncode = sharedPreferences.getInt("my_stored_data_number",0);
        return versioncode;
    }

    @Override
    public void saveMask(Context mContext,int mask) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        //得到SharedPreferences.Editor对象，并保存数据到该对象中
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putInt("my_mask",mask);
        editor.commit();
    }

    @Override
    public int takeMask(Context mContext) {
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        int my_mask = sharedPreferences.getInt("my_mask", 0);
        return my_mask;
    }

    @Override
    public ISFirstBean TakeISFirstDate(Context mContext) {
        ISFirstBean bean =  new  ISFirstBean();
        SharedPreferences sharedPreferences = mContext.getSharedPreferences("My_App_Cardiac", MODE_PRIVATE);
        String my_test_date = sharedPreferences.getString("my_test_date","");
        String my_test_result =  sharedPreferences.getString("my_test_result","");
        bean.setDatestr(my_test_date);
        bean.setResult(my_test_result);
        return bean;
    }
}
